package nina.yiyou.entry.run

class WorkshopEntryRunner {

  WorkshopEntryRunner(EntryArgParser.Arg args) {
    _args = args
  }

  void run() {
    String className = _args.getEntryClass()
    Class runnerType = Class.forName(className)

    String[] appArgs = _args.getAppArgs().toArray()
    runnerType.metaClass.methods
        .findAll { it.isStatic() }
        .findAll { it.name == 'main' }
        .each { it.invoke(null, [appArgs].toArray()) }
  }

  private final EntryArgParser.Arg _args
}
